<?php

/**
 * Subclass for representing a row from the 'customer' table.
 *
 * 
 *
 * @package lib.model
 */ 
class Customer extends BaseCustomer
{
	public static function getOrCreateByUser($userId)
	{
		if( $userId < 1 )
        {
        	$customer = null;
        }else 
        {
        	$c = new Criteria();
            $c->add(CustomerPeer::USER_ID, $userId);
            $c->addDescendingOrderByColumn(CustomerPeer::CREATED_AT);
            $c->setLimit(1);
            
            $customer = CustomerPeer::doSelectOne($c);
            if( empty($customer) )
            {
            	$customer = new Customer();
            	$customer->setUserId($userId);
            }
        }
        return $customer;
	}
	
}
